﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace CRM.Repository.Interface
{
    public interface I_Repository<T> where T : class, new()
    {
        /// <summary>
        /// 条件查询
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        IQueryable<T> QueryAll(Expression<Func<T, bool>>? where = null);

        IQueryable<T> QueryAll<type>(bool isAsc, Expression<Func<T, type>> order, Expression<Func<T, bool>>? where = null);

        IQueryable<T> QueryAll<type>(out int total, int skip, int take, bool isAsc, Expression<Func<T, type>> order, Expression<Func<T, bool>>? where = null);

        void Add(T entity);

        void AddRange(IEnumerable<T> ie);

        void Update(T entity);

        void UpdateRange(IEnumerable<T> ie);


        void Delete(T entity);

        void DeleteRange(IEnumerable<T> ie);

        int SaveChanges();

        /// <summary>
        /// 异步保存
        /// </summary>
        /// <returns></returns>
        Task<int> SaveChangesAsync();
        
    }
}
